package com.fitzone.web.controller.admin;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fitzone.common.result.Result;
import com.fitzone.model.dto.OrdersPageDTO;
import com.fitzone.model.vo.OrdersCoachVO;
import com.fitzone.model.vo.OrdersCourseVO;
import com.fitzone.model.vo.OrdersVipVO;
import com.fitzone.web.service.OrdersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RequestMapping("/admin/orders")
@RestController
@RequiredArgsConstructor
@Api(tags = "订单管理")
public class OrdersController {

    private final OrdersService ordersService;

    @GetMapping("/course/{page}/{limit}")
    @ApiOperation("查询课程订单")
    public Result<Page> page(OrdersPageDTO ordersPageDTO){
        Page<OrdersCourseVO> page = ordersService.pageCourse(ordersPageDTO);
        return Result.ok(page);
    }

    @GetMapping("/vip/{page}/{limit}")
    @ApiOperation("查询会员订单")
    public Result<Page> pageVip(OrdersPageDTO ordersPageDTO){
        Page<OrdersVipVO> page = ordersService.pageVip(ordersPageDTO);
        return Result.ok(page);
    }

    @GetMapping("/coach/{page}/{limit}")
    @ApiOperation("查询教练订单")
    public Result<Page> pageCoach(OrdersPageDTO ordersPageDTO){
        Page<OrdersCoachVO> page = ordersService.pageCoach(ordersPageDTO);
        return Result.ok(page);
    }

}
